﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_SubscibeProject]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_SubscibeProject];
GO
CREATE PROCEDURE [dbo].[sproc_SubscibeProject] 
    @StaffName nvarchar(300),
    @ClassID int
/*

============================================================
功能:    @StaffName订阅@ClassID组
参数:
    @StaffName nvarchar(300)    :    订阅者姓名(登陆名)
    @ClassID int            :    订阅的组（类）ID
============================================================

*/
As
Declare @StaffID int

Set @staffID =0

Select @staffid = staff_id From uds_staff Where staff_name = @staffname
If @staffid >0
    If not exists(Select 1 From uds_subscription where classid =@classid and staff_id = @staffid)
    Insert Into uds_subscription Values(@classid,@staffid,getdate())